package com.modbus.tcp.controller;

import java.util.List;

import com.modbus.tcp.utils.ApiReturnObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.modbus.tcp.domain.Wirelessdata;
import com.modbus.tcp.service.IWirelessdataService;


/**
 * 无线温度数据 信息操作处理
 *
 * @author d
 * @date 2024-07-11
 */
@RestController
@RequestMapping("/wirelessdata")
public class WirelessdataController  {

    @Autowired
    private IWirelessdataService wirelessdataService;

    /**
     * 查询无线温度数据列表
     */
    @GetMapping("/list")
    public ApiReturnObject list(Wirelessdata wirelessdata,Integer pageNum,Integer pageSize) {
        if(pageNum != null && pageSize !=null ){
            PageHelper.startPage(pageNum,pageSize);
        }
        List<Wirelessdata> list = wirelessdataService.selectWirelessdataList(wirelessdata);
        PageInfo pageInfo = new PageInfo<>(list);
        return new ApiReturnObject("200","查询成功",pageInfo);
    }


    /**
     * 新增保存无线温度数据
     */

    @PostMapping("/add")
    public ApiReturnObject addSave(@RequestBody Wirelessdata wirelessdata) {
        wirelessdataService.insertWirelessdata(wirelessdata);
        return new ApiReturnObject("200","添加成功","");
    }


    /**
     * 详情无线温度数据
     */
    @GetMapping("/selectOne")
    public ApiReturnObject selectOne(Integer id){
        Wirelessdata result = wirelessdataService.selectWirelessdataById(id);
        return new ApiReturnObject("200","查询成功",result);
    }

    /**
     * 修改保存无线温度数据
     */

    @PostMapping("/update")
    public ApiReturnObject editSave(@RequestBody Wirelessdata wirelessdata) {
        wirelessdataService.updateWirelessdata(wirelessdata);
        return new ApiReturnObject("200","修改成功","");
    }


    /**
     * 删除无线温度数据
     */
    @PostMapping("/del")
    public ApiReturnObject remove(String ids) {
        wirelessdataService.deleteWirelessdataByIds(ids);
        return new ApiReturnObject("200","删除成功","");
    }
}